package jnpf.zc.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jnpf.base.ActionResult;
import jnpf.fico.model.invoice.ZcglCwInvoiceListVO;
import jnpf.report.vo.*;
import jnpf.zc.entity.ZcglZcdjWarrantEntity;
import jnpf.zc.mapper.ReportMapper;
import jnpf.zc.mapper.ZcglZcdjWarrantMapper;
import jnpf.zc.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

/**
 * @description:
 * @author: zhengxiong.jiang
 * @createDate: 2025-09-08
 * @version: 1.0
 */
@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private ReportMapper reportMapper;
    @Autowired
    private ZcglZcdjWarrantMapper zcglZcdjWarrantMapper;


    @Override
    public IPage<ReportGyjyVO> getGyjyListPage(ReportGyjyVO reportGyjyVO) {
        return reportMapper.getGyjyListPage(new Page<ReportGyjyVO>(reportGyjyVO.getCurrentPage(), reportGyjyVO.getPageSize()),reportGyjyVO);
    }

    @Override
    public IPage<ZcglCzReportVO> getZcglCzReportVO(ZcglCzReportVO reportGyjyVO) {
        return reportMapper.getZcglCzReportVO(new Page<ZcglCzReportVO>(reportGyjyVO.getCurrentPage(), reportGyjyVO.getPageSize()),reportGyjyVO);

    }

    @Override
    public IPage<ReportGyzcVO> getGyzcListPage(ReportGyzcVO reportGyzcVO) {
        return reportMapper.getGyzcListPage(new Page<ReportGyzcVO>(reportGyzcVO.getCurrentPage(), reportGyzcVO.getPageSize()),reportGyzcVO);
    }

    @Override
    public IPage<ReportGyzcWqsVO> getGyzcWqsListPage(ReportGyzcWqsVO reportGyzcWqsVO) {
        return reportMapper.getGyzcWqsListPage(new Page<ReportGyzcWqsVO>(reportGyzcWqsVO.getCurrentPage(), reportGyzcWqsVO.getPageSize()),reportGyzcWqsVO);
    }

    @Override
    public IPage<ReportGyzcXzVO> getGyzcXzListPage(ReportGyzcXzVO reportGyzcXzVO) {
        return reportMapper.getGyzcXzListPage(new Page<ReportGyzcXzVO>(reportGyzcXzVO.getCurrentPage(), reportGyzcXzVO.getPageSize()),reportGyzcXzVO);
    }

    @Override
    public IPage<ReportGyzcCzVO> getGyzcCzListPage(ReportGyzcCzVO reportGyzcCzVO) {
        return reportMapper.getGyzcCzListPage(new Page<ReportGyzcCzVO>(reportGyzcCzVO.getCurrentPage(), reportGyzcCzVO.getPageSize()),reportGyzcCzVO);
    }

    @Override
    public ActionResult updateGyzcWqs(ReportGyzcWqsVO reportGyzcWqsVO) {
        ZcglZcdjWarrantEntity zcglZcdjWarrantEntity = new ZcglZcdjWarrantEntity();
        BeanUtil.copyProperties(reportGyzcWqsVO,zcglZcdjWarrantEntity);
        zcglZcdjWarrantEntity.setParentId(reportGyzcWqsVO.getFId());
        zcglZcdjWarrantMapper.update(zcglZcdjWarrantEntity,new QueryWrapper<ZcglZcdjWarrantEntity>()
                .eq("F_ParentId",zcglZcdjWarrantEntity.getParentId())
        );
        return ActionResult.success();
    }

    @Override
    public ActionResult updateGyzcXz(ReportGyzcXzVO reportGyzcXzVO) {
        ZcglZcdjWarrantEntity zcglZcdjWarrantEntity = new ZcglZcdjWarrantEntity();
        BeanUtil.copyProperties(reportGyzcXzVO,zcglZcdjWarrantEntity);
        zcglZcdjWarrantEntity.setParentId(reportGyzcXzVO.getFId());
        zcglZcdjWarrantMapper.update(zcglZcdjWarrantEntity,new QueryWrapper<ZcglZcdjWarrantEntity>()
                .eq("F_ParentId",zcglZcdjWarrantEntity.getParentId())
        );
        return ActionResult.success();
    }




}
